<?php

class tsw_dewPoint implements ThermdSingleWidget
{
  public function drawWidget($io,$x,$y)
  {	
		$dpr = ThermdStats::ts_readCurrent(ThermdStats::$dewpoint_log_id);
		
		if($dpr===FALSE)
		{ 
		  // if no dp value found in the DB, perform a calculation to generate one
		  $dewpoint = ThermdStats::ts_readCurrent(ThermdStats::$temperature_log_id - ((100 - $humidity) / 5 ));
      $dpr = number_format($dewpoint,2,'.','');
		}
		
		$grn = imagecolorallocate($io,0,132,0);
	
		imagestring($io,3,$x,$y,'Dew Point',$grn);
		imagestring($io,2,$x+8,$y+12,$dpr.ThermdStats::$units,$grn);
  }
}

?>